
Partial Class RIAssessments_AssessmentCosts
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, _
                            ByVal e As System.EventArgs) _
                            Handles Me.Load

        If Not Page.IsPostBack Then

            Me.CostTextBox.Text = Cdm.RIDataCore.Assessments.AssessmentCost.GetCost().Cost
            Me.CostTextBox.Text = FormatNumber(Me.CostTextBox.Text, 2)

        End If

    End Sub

    Protected Sub SaveButton_Click(ByVal sender As Object, _
                                   ByVal e As System.EventArgs) _
                                   Handles SaveButton.Click

        If IsNumeric(Me.CostTextBox.Text) Then

            Try

                Dim assessmentCost As Cdm.RIDataCore.Assessments.AssessmentCost = Cdm.RIDataCore.Assessments.AssessmentCost.GetCost
                assessmentCost.Cost = Me.CostTextBox.Text
                assessmentCost.Persist()
                Me.ShowMessage("Cost saved successfully.", Drawing.Color.Navy)

            Catch gentileEx As Gentle.Common.GentleException

                Me.ShowMessage("Cost failed to save.", Drawing.Color.Firebrick)

            Catch ex As Exception

                Me.ShowMessage("Cost failed to save.", Drawing.Color.Firebrick)

            End Try

        Else

            Me.ShowMessage("Please enter a valid dollar amount.", Drawing.Color.Firebrick)

        End If

    End Sub

    Private Sub ShowMessage(ByVal message As String, _
                            ByVal color As System.Drawing.Color)

        Me.MessageLabel.ForeColor = color
        Me.MessageLabel.Text = message
        Me.MessageLabel.Visible = True

    End Sub

End Class
